package 牛客周赛.牛客周赛Round85;

import java.util.Scanner;

/**
 * @Title: C
 * @Author 贾金博
 * @Package 牛客周赛.牛客周赛Round85
 * @Date 2025/4/8 上午10:02
 * @description: This is C
 */
public class C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t -- > 0 ) {
            String s = sc.next();
            int sum = 0;

            for(int i = 1; i < s.length(); i ++ ) {
                if(s.charAt(i) != s.charAt(i - 1)) {
                    sum ++ ;
                }
            }
            if(sum > 5) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        }
    }
}
